#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Time       :   21:37
# Author     : Y4
# Site       : 
# File       : 10 面向对象-多态.py
# Software   : PyCharm
'''
People、Pig、Dog为继承Animal类的三个不同子类。这三个子类都重写了父类的run方法,但是输出了不同的结果

'''


class Animal:
    def run(self):
        print('animal is running')


class People(Animal):
    def run(self):
        print('man is running')


class Pig(Animal):
    def run(self):
        print('pig is running')


class Dog(Animal):
    def run(self):
        print('dog is running')


people = People()
pig = Pig()
dog = Dog()

people.run()
pig.run()
dog.run()

print("*" * 50)




'''
方法的参数随对象所属的类不同,输出不同的结果
'''

def run_example(animal):
    animal.run()


run_example(people)
run_example(pig)
run_example(dog)
